<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="s_goods" :rules="rules" label-width="100px" id="mvcfm"> 公司 <el-select @change="list_l_firm" v-model="empty">
        <el-option label="－－无－－" value='' />
        <el-option v-for="dict in l_firm" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
      </el-select> 人员 <el-select @change="list_s_person" v-model="empty">
        <el-option label="－－无－－" value='' />
        <el-option v-for="dict in s_person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
      </el-select>
      <div>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 库存列表 </span>
      </div>
      <el-table :data="s_goods">
        <el-table-column label="操作" align="center" width='100' type=''>
          <template slot-scope="scope">
            <el-dropdown trigger="click">
              <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>
                  <el-link @click="d_goods('&CMIDgoods_id='+scope.row.goods_id+'')">删除</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popWarningmodificationUp('&CMIDproduct_id='+scope.row.product_id+'')">修改库存预警值</el-link>
                </el-dropdown-item>
                <el-dropdown-item>
                  <el-link @click="popModifyInventory('&CMIDgoods_id='+scope.row.goods_id+'')">修改库存数量</el-link>
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </template>
        </el-table-column>
        <el-table-column label="#" align="center" type='index'>
        </el-table-column>
        <el-table-column label="产品条形码" prop="product_barcode">
        </el-table-column>
        <el-table-column label="类型" prop="menu_class">
        </el-table-column>
        <el-table-column label="产品名称" prop="product_name">
        </el-table-column>
        <el-table-column label="产品型号" prop="product_model">
        </el-table-column>
        <el-table-column label="产品规格" prop="product_norm">
        </el-table-column>
        <el-table-column label="产品价格" prop="product_price">
        </el-table-column>
        <el-table-column label="仓库数量" prop="sum_num">
        </el-table-column>
        <el-table-column label="占用数量" prop="occupy_num">
        </el-table-column>
        <el-table-column label="库存预计值" prop="s_warning_value">
        </el-table-column>
        <el-table-column label="供应商" prop="client_name">
        </el-table-column>
        <el-table-column label="产品状态" prop="product_istran">
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :limit.sync="pageSize" @pagination="getPage" />
    </el-form>
    <el-dialog :visible.sync="WarningmodificationUpVisible" append-to-body>
      <WarningmodificationUp v-if="WarningmodificationUpVisible" ref="WarningmodificationUp" :popparams="popparams"> </WarningmodificationUp>
    </el-dialog>
    <el-dialog :visible.sync="ModifyInventoryVisible" append-to-body>
      <ModifyInventory v-if="ModifyInventoryVisible" ref="ModifyInventory" :popparams="popparams"> </ModifyInventory>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import WarningmodificationUp from "@/views/psi/supplychainmana/WarningmodificationUp";
  import ModifyInventory from "@/views/psi/supplychainmana/ModifyInventory";
  export default {
    name: 'StockQuery',
    components: {
      WarningmodificationUp,
      ModifyInventory,
    },
    props: ['popparams'],
    data() {
      return {
        WarningmodificationUpVisible: false,
        WarningmodificationUpValue: null,
        WarningmodificationUpDesc: null,
        ModifyInventoryVisible: false,
        ModifyInventoryValue: null,
        ModifyInventoryDesc: null,
        vueparams: this.getVUEParams(""),
        s_goods: [],
        l_firm: [],
        s_person: [],
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/StockAction/stockQuery?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_goods(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/supplychainmana/StockAction/d_goods?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
      list_l_firm(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMID7=" + value);
        } else if (this.$route.fullPath.indexOf("CMID7=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMID7=" + value);
        } else {
          this.gotoPage("/redirect/psi/supplychainmana/StockQuery?" + this.vueparams, {
            CMID7: value
          });
        }
      },
      list_s_person(value) {
        if (this.$route.fullPath.indexOf("?") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "?CMID8=" + value);
        } else if (this.$route.fullPath.indexOf("CMID8=") == -1) {
          this.$router.replace("/redirect" + this.$route.fullPath + "&CMID8=" + value);
        } else {
          this.gotoPage("/redirect/psi/supplychainmana/StockQuery?" + this.vueparams, {
            CMID8: value
          });
        }
      },
      popWarningmodificationUp(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.WarningmodificationUpVisible = !this.WarningmodificationUpVisible;
      },
      popModifyInventory(params) {
        if (params != "") this.popparams = params + this.vueparams;
        this.ModifyInventoryVisible = !this.ModifyInventoryVisible;
      },
    },
  }
</script>
